//
// Created by francklinson on 2021/12/2 AT 9:21.
// May Saint Diana bless you!
//

#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Solution {
public:
    int subtractProductAndSum(int n) {
        int x = 1, y = 0;
        while (n) {
            int lastBit = n % 10;
            x *= lastBit;
            y += lastBit;
            n /= 10;
        }
        return x - y;
    }
};

int main() {
    Solution solution;
    cout << solution.subtractProductAndSum(234) << endl;
    cout << solution.subtractProductAndSum(4421) << endl;
    return 0;
}

